<template>
  <div class="cp-worktab">
    <el-tabs :value="currentTab.name" type="border-card" @tab-remove="removeTab" @tab-click="clickTab">
      <el-tab-pane v-for="t in worktabs" :key="t.name" :label="t.authName" :name="t.name" :closable="t.name !== 'count'">
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  // created () {
  //   // 进来不是主页时等list加载后再更新一次current
  //   setTimeout(() => {
  //     this.activeTab = this.$store.state.worktab.current.name
  //   }, 500)
  // },
  computed: {
    ...mapGetters(['worktabs', 'currentTab'])
  },
  data () {
    return {
    }
  },
  methods: {
    clickTab (tab) {
      if (tab.name === this.currentTab.name) {
        return
      }
      this.$router.push(this.worktabs[1 * tab.index].path)
    },
    removeTab (name) {
      this.$store.dispatch('worktabRemove', name)
    }
  }
}
</script>
<style lang="less" scoped>
.cp-worktab .el-tabs--border-card {
  border: none;
  box-shadow: none;
}
</style>
